<?php 
if(!defined('ADMIN')){
	exit('Access Denied');
}
$subact=$_GET["subact"];



?>
<div class="accordion" fillSpace="sideBar">
<div class="accordionContent">
    <ul class="tree treeFolder expand">
<?php
    if($subact=="content"){
      
       function listcategory($parentid=0){
         global $ezhand,$modellist;
         $total=$ezhand->count("category","parentid=".$parentid);
         $row=$ezhand->select_all("category",'*',"parentid=".$parentid." order by listorder asc");
         $catlist=array();
         if(empty($row)){
                return $catlist;
         }
         $i=0;
         foreach ($row as $r){         
            $catid=$r["id"];
            $catsublist=listcategory($catid);
            $catlist[$catid]["catname"]=$r["catname"];
            $catlist[$catid]["catid"]=$catid;
            $catlist[$catid]["childlist"]=$catsublist;
         }
         
         return $catlist;
       }
       $catlist=listcategory(0);
       function showcatlist($catlist){
       foreach($catlist as $key=>$row){
            if(!empty($row["childlist"])){
                 echo "<li><a>".$row["catname"]."</a><ul>\n";
                 
                    showcatlist($row["childlist"]);
                 
                  echo "</ul></li>\n";                
            }else{
              echo "<li><a href=\"".u("content","list",array("catid"=>$row["catid"]))."\" target=\"navTab\" fresh=\"true\" rel=\"page".$row["catid"]."\">".$row["catname"]."</a></li>\n";   
            }
        
        
       }
       }
       showcatlist($catlist);
       // print_r($catlist);
        
    }else{
    
    
        $i=1;
        $j=0;
        //pp($menu_arr);
        foreach($menu_arr as $key=>$row){

            if(empty($submenulist[$key])){
                    continue;
            }
            if($parent_menu[$key]['hide']==0){
            ?>
                <li><a><?=$parent_menu[$key]['title']?></a>
                <ul>
                    <?php foreach($row as $arr){if($arr['hide']==0){?>
                    <li><a href="<?=u($arr['mod'],$arr['act'])?><?=$arr['addtion']?>" target="navTab" fresh="true" rel="page<?=$arr["id"]?>"><?=$arr['title']?></a></li>
                    <?php $j++; }}?>
                </ul>
               </li>
              <?php
               }
              $i++;
          }
      
      }
      ?>
      </ul> 
</div>
</div>
